#include "CFGNode.h"
#include "TreeNode.h"
#include "assert.h"
using namespace std;

//int mContent;
//vector<CFGNode*> mPredecessorsList;
//vector<CFGNode*> mSuccessorsList;
//TreeNode* mASTNodeLink;


//If content is -2, then cannot add successors
CFGNode::CFGNode(){
	mContent = -2;
}

CFGNode::CFGNode(int content, TreeNode* ASTNode){
	assert (content != NULL);
	assert (content > 0);
	assert(ASTNode);
	mContent = content;
	mASTNodeLink = ASTNode;
}
CFGNode::~CFGNode(void){
	mContent = -1;
	mPredecessorsList.clear();
	mSuccessorsList.clear();
	mASTNodeLink = NULL;
}

bool CFGNode::setASTNodeLink(TreeNode* ASTNode){
	assert(ASTNode);
	mASTNodeLink = ASTNode;
	return true;
}
TreeNode* CFGNode::getASTNodeLink(){
	assert (mContent != -2);
	return mASTNodeLink;
}

void CFGNode::setContent(int content){
	assert (content != NULL);
	assert (content > 0);
	mContent = content;
}
int CFGNode::getContent(){
	return mContent;
}

void CFGNode::addSuccessor(CFGNode* succ){
	assert(succ);
	mSuccessorsList.push_back(succ);
}
void CFGNode::addPredecessor(CFGNode* pred){
	assert(pred);
	mPredecessorsList.push_back(pred);
}
vector<CFGNode*> CFGNode::getSuccessor(){
	return mSuccessorsList;
}

int CFGNode::getNumberOfSuccessor(){
	assert (mContent != -2);
	return mSuccessorsList.size();
}
vector<CFGNode*> CFGNode::getPredecessor(){
	return mPredecessorsList;
}
int CFGNode::getNumberOfPredecessor(){
	return mPredecessorsList.size();
}